<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>创客手机网站</title>
  <script src="/wap/js/flexible.js"></script>
  <script src="/wap/js/jquery-3.2.1.min.js"></script>
  <script src="/wap/js/util.js"></script>
  <link rel="stylesheet" href="/wap/css/style.css?={{ time() }}">
  <style>
    html,body{
      height: 100%;
    }
  </style>
</head>
<body>
  <div id="login" class="login" style="height: 100%;">
    <div class="login__logo">
      <img src="/wap/image/logo.png" alt="">
    </div>
    <div class="login__form">
      <input type="hidden" name="_token" value="{{csrf_token()}}">
      <div class="login__form__input">
        <div class="input__mobile">
          <input class="input" type="text" maxlength="11" name="mobile" placeholder="手机号码">
        </div>
        <div class="input__password" style="margin-top: 1px">
          <input class="input" type="password" name="password" placeholder="登录密码">
        </div>
      </div>
      <div class="login__form__btn">登录</div>
    </div>
    <div class="modify__pwd" onclick="location.href='/wap/index/changePassword'">修改登陆密码</div>
  </div>
</body>
</html>

<script>
  $('.login__form__btn').on('click', function() {
      var mobile = $('input[name="mobile"]').val();
      var password = $('input[name="password"]').val();
      var csrf_token = $('input[name="_token"]').val();
      if(mobile == ''){
          toast('未输入手机号！',1000);
          $('input[name="mobile"]').focus();
          return false;
      }
      if(password == ''){
          toast('未输入密码！',1000);
          $('input[name="password"]').focus();
          return false;
      }
      $.ajax({
          type: 'post',
          url: '{{ route('wap.index.ajaxLogin') }}',
          data: {'mobile':mobile,'password':password,'_token':csrf_token},
          dataType: "JSON",
          async: false,
          success: function (res) {
              if(res.status=="FAIL"){
                  toast(res.message,2000);
              }else{
                  window.location.href = res.url;
              }
          },
          error: function (res) {
              console.log(res, 'error');
          }
      });
  })
</script>